package com.xxchat.controller;

import com.xxchat.annotation.GlobalInterceptor;
import com.xxchat.entity.constants.QueryConstants;
import com.xxchat.entity.po.GroupInfo;
import com.xxchat.entity.query.GroupInfoQuery;
import com.xxchat.entity.vo.PaginationResultVO;
import com.xxchat.entity.vo.ResponseVO;
import com.xxchat.service.GroupInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @author Waicc
 */
@RestController("adminGroupController")
@RequestMapping("/admin")
public class AdminGroupController extends ABaseController {
    @Resource
    private GroupInfoService groupInfoService;

    @RequestMapping("/loadGroup")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO loadGroup(Integer pageSize, @NotNull Integer pageNum) {
        // TODO 搜索功能
        PaginationResultVO<GroupInfo> resultVO = this.groupInfoService.loadGroupList(pageSize, pageNum);
        return getSuccessResponseVO(resultVO);
    }

    @RequestMapping("/forceDisbandGroup")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO forceDisbandGroup(@NotEmpty String groupId) {
        this.groupInfoService.forceDisbandGroup(groupId);
        return getSuccessResponseVO(null);
    }
}
